package cn.yunyichina.provider.pay.wechat.service;

import cn.yunyichina.provider.pay.wechat.entity.common.WechatCommonResponse;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * Created by Lullaby on 2016/10/27.
 */
public class BaseService {

    @Resource
    private Properties yaml;

    protected String getConfig(String key) {
        return yaml.getProperty(key);
    }

    protected Map<String, String> getWechatReturnCodeAndMsg(WechatCommonResponse response) {
        Map<String, String> result = new HashMap<>();

        result.put("return_code", response.getReturnCode());
        result.put("return_msg", response.getReturnMsg());

        return result;
    }

    protected Map<String, String> getWechatReturnCodeAndMsg(String returnCode, String returnMsg) {
        Map<String, String> result = new HashMap<>();

        result.put("return_code", returnCode);
        result.put("return_msg", returnMsg);

        return result;
    }

    protected Map<String, String> getWechatErrCodeAndDes(WechatCommonResponse response) {
        Map<String, String> result = new HashMap<>();

        result.put("err_code", response.getErrCode());
        result.put("err_code_des", response.getErrCodeDes());

        return result;
    }

    protected Map<String, String> getWechatErrCodeAndDes(String errCode, String errCodeDes) {
        Map<String, String> result = new HashMap<>();

        result.put("err_code", errCode);
        result.put("err_code_des", errCodeDes);

        return result;
    }

    protected Map<String, String> getWechatErrcodeAndmsg(WechatCommonResponse response) {
        Map<String, String> result = new HashMap<>();

        result.put("errcode", response.getErrcode());
        result.put("errmsg", response.getErrmsg());

        return result;
    }

    protected Map<String, String> getWechatErrcodeAndmsg(String errcode, String errmsg) {
        Map<String, String> result = new HashMap<>();

        result.put("errcode", errcode);
        result.put("errmsg", errmsg);

        return result;
    }

}
